﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title></title>
    <link href="qunit.css" rel="stylesheet" type="text/css" />

    <script src="jquery-1.4.1.js" type="text/javascript"></script>

    <script src="qunit.js" type="text/javascript"></script>

    <script type="text/javascript">
        try {
            var JSON_NATIVE = JSON;
        }
        catch (e) { }
        
    </script>

    <script src="json2.forced.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function() {




            function testReplacer() {
                var obj = new testOjb();
                var s = JSON.stringify(obj, function(key, value) {
                    if (key == "date") {
                        return String("SERIALIZED");
                    }
                    return value;
                });

                var sobj = JSON.parse(s);
                ok(typeof sobj.date == "string", "Expect output member is string");
                ok(sobj.date == "SERIALIZED", "Expect output member = 'SERIALIZED', got " + sobj.date);

                ok(obj.date instanceof Date, "Expect input member is Date");
                ok(!isNaN(obj.date.getTime()), "Expect input member is Valid");
            }
            var testOjb = function() {
                this.date = new Date(2009, 1, 1, 10, 10);
            }





            module("Script JSON");

            test("Script Replacer", function() {
                stop();
                testReplacer();
                start();
            });


            
            module("Native JSON");
            if (typeof JSON_NATIVE === 'undefined') {
                test("NO NATIVE JSON", function() {
                });
            }
            else {

                test("Native Replacer", function() {

                stop();
                JSON = JSON_NATIVE;
                    testReplacer();
                    start();
                });
            }

        });


        
    
    </script>

</head>
<body>
    <h1 id="qunit-header">
        JSON api tests. json2.js vs Native implementations</h1>
    <h2 id="qunit-banner">
    </h2>
    <h2 id="qunit-userAgent">
    </h2>
    <ol id="qunit-tests">
    </ol>
</body>
</html>
